//用户
var level = (val => {
	switch(val) {
		case 'super':
			return '超级管理员'
		case 'server':
			return '客服'
		case 'finance':
			return '财务'
		case 'manager':
			return '管理员'
		case 'tech':
			return '技术'
		case 'business':
			return '商务'
		case 'server':
			
			
			
		
	}
})
//订单全部状态
const states=(order => {
	let value = {};
	switch(order.workflow_state){
		case 'new' : 
			value["name"] = "待接单"
			value["type"] = "default"
			value["index"] = 0
			break
		case 'appointed_measurement' :
			value["name"] = "待测量"
			value["type"] = "primary"
			value["index"] = 1
			break
		case 'measured' : 
			value["name"] = "待审核"
			value["type"] = "success"
			value["index"] = 2
			break
//		case '' : return '待运输'  
		case 'appointed_installation' :
			value["name"] = "待安装"
			value["type"] = "warning"
			value["index"] = 4
			break
		case 'installed' :
			value["name"] = "待确认"
			value["type"] = "gray"
			value["index"] = 5
			break
		case "confirm_installed":
			value["name"] = "待确认"
			value["type"] = "gray"
			value["index"] = 5
			break
		case 'completed' :
			value["name"] = "已完成"
			value["type"] = "default"
			value["index"] = 6
			break
		default:
			value = "--"
	}
	//待运输
	if(order.ship_status && order.brand_confirm==true){
		value["name"] = "待运输"
		value["type"] = "default"
		value["index"] = 3
	}
	return value
 })
//状态
const orderStates =(order=>{
	const result=states(order)
	return result.name
})
//订单现状态
const orderStateIndex = (order => {
	const result=states(order)
	return result.index
})
//发票
const conver_invoice = (state => {
	let value = {};
	switch(state) {
		case "audit":
			value["str"] = "待处理"
			value["type"] = "default"
			break;
		case "complete":
			value["str"] = "已开票"
			value["type"] = "primary"
			break;
		case "ship":
			value["str"] = "已寄出"
			value["type"] = "success"
			break;
		default:
			value = "--"
			break;
	}
	return value
})
//时间
const conver_time = (time => {
	let date = new Date(parseInt(time) * 1000)
	let year = date.getFullYear()
	let month = date.getMonth() >= 9 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1)
	let day = date.getDate() >= 10 ? date.getDate() : "0" + date.getDate()
	let hour = date.getHours() >= 10 ? date.getHours() : "0" + date.getHours()
	let minute = date.getMinutes() >= 10 ? date.getMinutes() : "0" + date.getMinutes()
	let second = date.getSeconds() >= 10 ? date.getSeconds() : "0" + date.getSeconds()
	return year + "-" + month + "-" + day + "   " + hour + ":" + minute + ":" + second
})
//余额
const conver_money = (price => {
	if(!price || price == "" || parseFloat(price) <= 0.0) {
		return "¥ 0.00"
	}
	price = parseFloat(price) / 100
	return price.toLocaleString('zh-CN', { style: 'currency', currency: 'CNY' })
})
const objectExist = (obj => {
	return Object.keys(obj).length > 0
})
//评分
const scores = (obj => {
	if(!obj || obj == "" || parseFloat(obj) <= 0.0) {
		return "0.00"
	}
	return obj.toFixed(2)
})
// 属性为空时的显示
const adres = (region => {
	if(!region || region == "" || region == undefined) {
		return "--"
	}
})
//职能类型
const jobType=(type=>{})
export default {
	conver_invoice: conver_invoice,
	conver_time: conver_time,
	conver_money: conver_money,
	objectExist: objectExist,
	level: level,
	adres: adres,
	scores: scores,
	states:states,
	orderStateIndex:orderStateIndex,
	orderStates:orderStates
}